package com.zing.controller.admin;

import com.zing.result.Result;
import com.zing.service.WorkspaceService;
import com.zing.vo.BusinessDataVO;
import com.zing.vo.DishOverViewVO;
import com.zing.vo.OrderOverViewVO;
import com.zing.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.LocalTime;

// 工作台接口
@RestController
@RequestMapping("/admin/workspace")
@Slf4j
@Api(tags = "工作台接口")
public class WorkSpaceController {

    @Autowired
    private WorkspaceService workspaceService;

    // 今日数据
    @GetMapping("/businessData")
    @ApiOperation("今日数据")
    public Result<BusinessDataVO> businessData(){
        // LocalDateTime.now() 获取的是当前日期时间，包括日期和时间两部分
        // with(LocalTime.MIN) 方法，该方法返回一个新的 LocalDateTime 对象，其中日期部分与调用对象相同，而时间部分被设置为当天的最小时间（00:00）。
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);

        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin, end);
        return Result.success(businessDataVO);
    }

    // 查询订单管理模块数据
    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单管理模块数据")
    public Result<OrderOverViewVO> orderOverView(){
        OrderOverViewVO orderOverViewVO = workspaceService.getOrderOverView();
        return Result.success(orderOverViewVO);
    }

    // 查询菜品总览
    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public Result<DishOverViewVO> dishOverView(){
        DishOverViewVO dishOverViewVO = workspaceService.getOverviewDishes();
        return Result.success(dishOverViewVO);
    }

    // 查询套餐总览
    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐总览")
    public Result<SetmealOverViewVO> setmealOverView(){
        SetmealOverViewVO setmealOverViewVO = workspaceService.getOverviewSetmeals();
        return Result.success(setmealOverViewVO);
    }
}
